home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-13 / amac44d.zip / SRQ.QM < prev    next >
Text File  |  1992-06-22  |  7KB  |  129 lines

  1. *                                 SRQ.QM
  2. *     Search/Replace Using SRQ.BAT, Quit Each File After Replacement
  3. *                                 6/8/92
  4. *
  5. * ----------------------------------------------------------------------
  6. * @(5) Search/Replace From Command Line Using SRQ.BAT,
  7. *      Quit Each File After Replacement
  8. *      Can Also Remove Search Text
  9. * ----------------------------------------------------------------------
  10. * Often the total size of files needing a "replacement" will exceed the
  11. * available memory when using SR.BAT with SR.QM.  Macro @5 in SRQ.QM is
  12. * simply a modification of @0 in SR.QM by replacing 'SaveFile' with
  13. * 'File' so each file is saved then quit after replacement.
  14. * Search/replace is performed by running SRQ.BAT.
  15.  
  16. * To do a search/replace from command line, type SR and answer prompts
  17. * for search and replacement text.  This version of this macro, a
  18. * modification of previous versions of SR.QM, enables the user to also
  19. * REMOVE search text by hitting <enter> at the replacement text prompt.
  20. * Versions with Amac43.zip and prior required that some replacement
  21. * text be entered at the replacement text prompt.
  22.  
  23. * FGREP.COM, INPUT.COM and QEdit v2.15 are required.  Changing c:\ to
  24. * your ram drive will increase speed.  Please refer to SR.BAT and SR.QM
  25. * for other details concerning entering optional parameters at the
  26. * command line or in response to input query prompts.
  27.  
  28. @5      macrobegin
  29.         setsoundoff
  30.         altwordset                * For all file names
  31.         cursordown cursorup
  32.         jtrue START               * Test if any search text found
  33.     * --------------- Display "No found text" Message ---------------*
  34.     MESSAGE:
  35.         "No found text"                                                    *|
  36.         jump END                  * If not found, display this
  37.     * -------------------------- Load Files --------------------------*
  38.     START:
  39.         endfile
  40.     LOADAGAIN:
  41. *         unmarkblock               * Unmark last file name                *|
  42.         setscreenon setscreenoff  * To reduce flashing
  43.         find
  44.             #42 "Fi" return
  45.             "B"  return           * Find file name
  46.         jfalse MESSAGE            * No find ?, show message, end
  47.         wordright wordright
  48.         markcolumn endline copy   * Copy file name to scrap
  49.         EditFile
  50.             CurrentFilename " "
  51.             Paste Return          * Load file
  52.         cursorup jtrue LOADAGAIN  * Test if more filenames?
  53.     * ------------------ Get Search Text To Scratch ------------------*
  54.         editfile "c:\$" return    * Load set output file
  55.         find
  56.             "S~~" return
  57.             delline return        * Find S~~ in SET output
  58.         find
  59.             "=" return
  60.             delline return        * Move to =
  61.         cursorright markcharacter * Mark first character
  62.         endline                   * Move to end of text
  63.         storescrbuff "S~~" return * Store SEARCH text to scratch
  64.     * ----------------- Get Replace Text To Scratch -----------------*
  65.         unmarkblock begfile
  66.         find
  67.             "R~~" return
  68.             delline return        * Find
  69.         jtrue FOUND               * If found, we specified replacement text*|
  70.         endline markcolumn        * If not, make empty block to clear buff *|
  71.         jump BLANK                                                         *|
  72.     FOUND:                                                                 *|
  73.         find
  74.             "=" return
  75.             delline return        * Move to =
  76.         cursorright markcharacter * Mark first character
  77.         endline                   * Move to end of text
  78.     BLANK:                                                                 *|
  79.         storescrbuff "R~~" return * Store REPLACE text to scratch
  80. *       killfile quit             * Kill/quit c:\$                         *|
  81.     * ---------------------- Do Search/Replace ----------------------*
  82. *       Editfile "NUL" Return     * Load NUL File                          *|
  83.         getscrbuff "S~~" return
  84.         cut                       * Cut search text from scratch
  85.         Find paste Return escape  * Initialize find prompt
  86.         getscrbuff "R~~" return
  87.         cut                       * Cut replace text from scratch
  88.         FindReplace
  89.             return paste return   * Begin replacement
  90.            "GIN"                  * Replace options
  91. *           pause                 ** Add this to pause for options
  92.             return                *   MUST include "GIN"
  93.         killfile quit             * Kill/quit c:\$                         *|
  94.     * ---------------- Load Files, Do Search/Replace ----------------*
  95.         Begfile Cursorright       * Put cursor in col 2  c:\!              *|
  96. *       Begline Cursorright       * Put cursor in col 2                    *|
  97.         setscreenon                                                        *|
  98.         LOOP:
  99.             Nextfile
  100.             Cursorleft Jfalse DOIT
  101.             Cursorleft Jfalse ENDLOOP
  102.         DOIT:                     * FindReplace Loop
  103.             BegFile               * Move up in case cursor is below find
  104.             Repeatfind            * Do the FindReplace
  105.             Jtrue SAVE            * If CHANGES are made -- SAVE the File
  106.             Quit                  * If NO CHANGES are made -- QUIT the file
  107.             Jump LOOP             * Return to the Main Loop
  108.         SAVE:                     * Routine to Save a File with Changes
  109.             FILE                  * Save and quit this file after rplcmnmt
  110.             Jump LOOP             * Return to Main Loop
  111.         ENDLOOP:                  * Loop is DONE
  112.             Quit                  * Quit c:\!, only file left in ring
  113.             editfile escape       * If Qconfig set to edit prompt on quit  *|
  114.  END:
  115. *           defaultwordset                                                 *|
  116. *
  117. * 153 bytes Tue  10-02-1990  18:50:33
  118. * 200 bytes Thu  04-25-1991  12:02:23 added "No found text" message
  119. *                                     added "GIN" auto replace option
  120. *                                     changed file "_" to NUL", faster
  121. *                                     changed "c:" to "c:\"
  122. * 208 bytes Tue  04-30-1991  22:16:22 changed search and replace to scrap
  123. * 211 bytes Wed  04-15-1992  17:55:38 (TH @4, for QEdit v2.15)
  124. * 211 bytes Wed  04-22-1992  00:15:22 (TH @5, changed key)
  125. *                 (In Amac42e.zip)
  126. * 209 bytes Mon  06-01-1992  17:04:36 (TH @5, will remove search text *|)
  127.  
  128.  
  129.